﻿/* 
 *  运行顺序
 *  
 *  EditBaseInfo() -> Edit Form -> click ↓
 *  SaveBaseInfo() -> Show Form -> click ↑
 *
*/
var number;
var now = new Date();
var nowdate=now.toLocaleDateString().toString();

function jsonToString(obj){   
    var THIS = this;    
    switch(typeof(obj)){   
        case 'string':   
            return '"' + obj.replace(/(["\\])/g, '\\$1') + '"';   
        case 'array':   
            return '[' + obj.map(THIS.jsonToString).join(',') + ']';   
        case 'object':   
             if(obj instanceof Array){   
                var strArr = [];   
                var len = obj.length;   
                for(var i=0; i<len; i++){   
                    strArr.push(THIS.jsonToString(obj[i]));   
                }   
                return '[' + strArr.join(',') + ']';   
            }else if(obj==null){   
                return 'null';   
            }else{   
                var string = [];   
                for (var property in obj) string.push(THIS.jsonToString(property) + ':' + THIS.jsonToString(obj[property]));   
                return '{' + string.join(',') + '}';   
            }   
        case 'number':   
            return obj;   
        case false:   
            return obj;   
    }   
}   

//设置select中text="optionValue"的第一个Item为选中        
function SelectItemByValue(id,optionValue){
    for (var i = 0; i < document.getElementById(id).options.length; i++) {    
        if (document.getElementById(id).options[i].value == optionValue) {  
            document.getElementById(id).options[i].selected = true;
            break;
        }
    }     
}
function SelectItemByText(id,optionText){
    for (var i = 0; i < document.getElementById(id).options.length; i++) {    
        if (document.getElementById(id).options[i].text == optionText) {  
            document.getElementById(id).options[i].selected = true;
            break;
        }
    }     
}
function getSelectOption(optionvalue){
 switch(optionvalue){
    case "无经验":return "0";break;
    case "一年以下":return "1";break;
    case "两年以下":return "2";break;
    case "三年以下":return "3";break;
    case "三年以上":return "4";break;
    case "0":return "无经验";break;
    case "1":return "一年以下";break;
    case "2":return "两年以下";break;
    case "3":return "三年以下";break;
    case "4":return "三年以上";break;
    //case false:return "数据异常";break;
 }
}
function openfile() 
{ 
try{ 
    var fd = new ActiveXObject("MSComDlg.CommonDialog"); 
    fd.Filter = "图像文件 (*.jpg;*.jpeg;*.gif)|*.jpg;*.jpeg;*.gif"; 
    fd.FilterIndex = 2;      
    // 必须设置MaxFileSize. 否则出错 
    fd.MaxFileSize = 128; 
    fd.ShowOpen(); 
    $("#fileToUpload").val(fd.Filename); 
    //$("#textImage")[0].src = $("#txtFileName").val(); 
    }catch(e){alert("你的浏览器不支持ActiveX！\r\n请启用ActiveX后重试．");$("#fileToUpload").val("");} 
}

function runEffect(id){
	//get effect type from 
	var selectedEffect = "highlight";
	
	//most effect types need no options passed by default
	var options = {};
	//check if it's scale, transfer, or size - they need options explicitly set
	//if(selectedEffect == 'scale'){  options = {percent: 100}; }
	//else if(selectedEffect == 'transfer'){ options = { to: "#button", className: 'ui-effects-transfer' }; }
	//else if(selectedEffect == 'size'){ options = { to: {width: 280,height: 185} }; }
	
	//run the effect
	$(id).show(selectedEffect,options,500,callback);
};

//callback function to bring a hidden box back
function callback(){
	setTimeout(function(){
		$(".saveMsg:visible").removeAttr('style').hide().fadeOut();
	}, 300);
};

function ajaxFileUpload(){ 
    loading();//动态加载小图标 
    $.ajaxFileUpload({ 
        url:'/Files.ashx', 
        secureuri:false, 
        fileElementId:'fileToUpload', 
        dataType: 'json', 
        success: function (data, status){
            if(typeof(data.error) != 'undefined'){
                if(data.error != ''){ 
                //alert(data.error); 
                }else{
                //alert(data.msg); 
                } 
            }
                $("#dialog").dialog("close");
                $(".saveMsg").html("<p>上传成功</p>");
                //runEffect(".saveMsg");
        }, 
        error: function (data, status, e){ 
            alert(e); 
        }
        
    }) 
} 
function loading(){ 
    $("#loading").ajaxStart(function(){ 
        $(this).show(); 
    })
    .ajaxComplete(function(){ 
        $(this).hide(); 
    }); 
}

function showDialog(){
    // Dialog			
    $('#dialog').dialog({
        bgiframe: true,
        autoOpen: false,
        width: 400,
        //height:80,
        modal: true,
        buttons: {
            "Cancel": function() { 
                $(this).dialog("close"); 
            },  
            "Ok": function() {
                //$("#fileToUpload").hide();
                ajaxFileUpload();
                //$(this).dialog("close");
            }
        }
    });
    // Dialog Link
    $('#dialog_link').click(function(){
        $('#dialog').dialog('open');
        //return false;
    });
}

function getHTML(info_id){ 
   //var xmlhttp=new ActiveXObject("Msxml2.xmlhttp");
   var xmlhttp;
   try
   {
         // Firefox, Opera 8.0+, Safari
         xmlhttp=new XMLHttpRequest();
   }
   catch (e)
   {
        // Internet Explorer
        try
        {
          xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
           xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
   }
   xmlhttp.open("GET","/Browser/Resume/" + info_id + ".htm",false);
   xmlhttp.send();
   return xmlhttp.responseText;
   //$("#" + info_id).html(xmlhttp.responseText);
}




function editInfo(info_id)
{
	//var numbers = Math.random();
	var str;
	getNumber(info_id);
	//alert(number);
	switch(info_id)
	{
		case "BPI_info":
            var baseInfo="{\"data\":[{\"Name\":\""+$("#rName").html()+"\",\"Born\":\""+$("#rBorn").html()+"\",\"Phone\":\""+$("#rPhone").html()+"\",\"Email\":\""+$("#rEmail").html()+"\",\"Address\":\""+$("#rAddress").html()+"\",\"WorkYears\":\""+$("#rWorkYears").html()+"\",\"Sex\":\""+$("#rSex").html()+"\",\"Birth\":\""+$("#rBirth").html()+"\"}]}";
            var json=eval("("+baseInfo+")");
            $.each(json.data,function(idx,item){
                var workYears=getSelectOption(item.WorkYears);
		        str=getHTML("BPI_info");
		        str = str.replace(/BPI_Button/g,"<img src=images_1/btn_save.gif onclick=Resume_save('BPI_info'); style=cursor:pointer><br><div class=saveMsg></div>");
		        str = str.replace(/XName/g,"<input name=rName type=text class=textfield id=rName value="+item.Name+">");
		        str = str.replace(/XSex/g,"<select class=selectfield name=rSex id=rSex value="+item.Sex+"><option value=男>男</option><option value=女>女</option></select>");
		        str = str.replace(/XBirth/g,"<INPUT class=selebg2 style=CURSOR: hand title=请选择日期 type=button value="+item.Birth+" id=rBirth>");
		        str = str.replace(/XWorkYears/g,"<select class=selectfield name=rWorkYears id=rWorkYears value="+workYears+"><option value=0>无经验</option><option value=1>一年以下</option><option value=2>两年以下</option><option value=3>三年以下</option><option value=4>三年以上</option></select>");
		        str = str.replace(/XAddress/g,"<INPUT class=selebg2 style=CURSOR: hand title=请选择地点 type=button value="+item.Address+" id=rAddress name=rAddress onClick=perNativeClick();></span>");
		        str = str.replace(/XEmail/g,"<input name=rEmail type=text class=textfield id=rEmail value="+item.Email+">");
		        str = str.replace(/XPhone/g,"<input name=rPhone type=text class=textfield id=rPhone value="+item.Phone+">");
		        str = str.replace(/XBorn/g,"<input name=rBorn type=button class=selebg2 style=CURSOR: hand id=rBorn value="+item.Born+" onClick=perNativeClick();>");
	            $("#BPI_info").html(str);
		        $(function() {$('#rBirth').datepicker({changeMonth: true,changeYear: true});});
                showDialog();
		        SelectItemByValue("rSex",item.Sex);SelectItemByText("rWorkYears",item.WorkYears);
            })
		break;
		case "Edu_info":
            var baseInfo="{\"data\":[{\"Edu_Time\":\""+$("#rEdu_Time").html()+"\",\"Edu_School\":\""+$("#rEdu_School").html()+"\",\"Edu_Subject\":\""+$("#rEdu_Subject").html()+"\",\"Edu\":\""+$("#rEdu").html()+"\",\"Edu_Degree\":\""+$("#rEdu_Degree").html()+"\"}]}";
            var json=eval("("+baseInfo+")");
            $.each(json.data,function(idx,item){
		        str=getHTML("Edu_info");
		        str = str.replace(/Edu_Button/g,"<img src=images_1/btn_save.gif onclick=Resume_save('Edu_info'); style=cursor:pointer><br><div class=saveMsg></div>");
		        str = str.replace(/XEdu_Time/g,"<input class=selebg2 style=CURSOR: hand title=请选择日期 type=button value="+$("#rEdu_Time").html()+" id=rEdu_Time>");
		        str = str.replace(/XEduu/g,"<select class=selectfield name=rEdu id=rEdu value="+$("#rEdu").html()+"><option>无</option><option>小学</option><option>初中</option><option>高中</option><option>中专</option><option>大专</option><option>本科</option></select>");
		        str = str.replace(/XEdu_Degree/g,"<select class=selectfield name=rEdu_Degree id=rEdu_Degree value="+$("#rEdu_Degree").html()+"><option>无</option><option>学士</option><option>硕士</option><option>博士</option></select>");
		        str = str.replace(/XEdu_School/g,"<input name=rEdu_School type=text class=textfield id=rEdu_School value="+$("#rEdu_School").html()+">");
		        str = str.replace(/XEdu_Subject/g,"<input name=rEdu_Subject type=text class=textfield id=rEdu_Subject value="+$("#rEdu_Subject").html()+">");
	            $("#Edu_info").html(str);
		        $(function() {$('#rEdu_Time').datepicker({changeMonth: true,changeYear: true});});
		        SelectItemByText("rEdu",item.Edu);
		        SelectItemByText("rEdu_Degree",item.Edu_Degree);
            })
		break;
		case "Work_info_"+number:
            var baseInfo="{\"data\":[{\"StarTime\":\""+$("#rStarTime_"+number).html()+"\",\"EndTime\":\""+$("#rEndTime_"+number).html()+"\",\"Company\":\""+$("#rCompany_"+number).html()+"\",\"Industry\":\""+$("#rIndustry_"+number).html()+"\",\"Department\":\""+$("#rDepartment_"+number).html()+"\",\"Position\":\""+$("#rPosition_"+number).html()+"\",\"Memo\":\""+$("#rMemo_"+number).html()+"\"}]}";
            var json=eval("("+baseInfo+")");
            $.each(json.data,function(idx,item){
		        str=getHTML("Work_info");
		        str = str.replace(/XNumber/g,number);
		        str = str.replace(/Work_Button/g,"<img src=images_1/btn_save.gif onclick=Resume_save('Work_info_"+number+"') style=cursor:pointer><br><a href=\"javascript:void(0);\" onclick=\"deleteinfo('Work_info_"+number+"')\">删除</a><div class=saveMsg></div>");
		        str = str.replace(/XStartTime/g,"<input class=selebg2 style=CURSOR: hand title=请选择日期 type=button value="+$("#rStartTime_"+number).html()+" id=rStartTime_"+number+"\>");
		        str = str.replace(/XEndTime/g,"<input class=selebg2 style=CURSOR: hand title=请选择日期 type=button value="+$("#rEndTime_"+number).html()+" id=rEndTime_"+number+"\>");
		        str = str.replace(/XCompany/g,"<input name=rCompany_"+number+" type=text class=textfield id=rCompany_"+number+" value="+$("#rCompany_"+number).html()+"\>");
		        str = str.replace(/XIndustry/g,"<input name=rIndustry_"+number+" type=text class=textfield id=rIndustry_"+number+" value="+$("#rIndustry_"+number).html()+"\>");
		        str = str.replace(/XDepartment/g,"<input name=rDepartment_"+number+" type=text class=textfield id=rDepartment_"+number+" value="+$("#rDepartment_"+number).html()+"\>");
		        str = str.replace(/XPosition/g,"<input name=rPosition_"+number+" type=text class=textfield id=rPosition_"+number+" value="+$("#rPosition_"+number).html()+"\>");
		        str = str.replace(/XMemo/g,"<input name=rMemo_"+number+" type=text class=textfield id=rMemo_"+number+" value="+$("#rMemo_"+number).html()+"\>");
		        //alert(str);
	            $("#Work_info_"+number).html(str);
		        $(function() {$('#rStartTime_'+number).datepicker({changeMonth: true,changeYear: true});});
		        $(function() {$('#rEndTime_'+number).datepicker({changeMonth: true,changeYear: true});});
            })
		break;
		case "Skill_info_"+number:
            var baseInfo="{\"data\":[{\"SkillName\":\""+$("#rSkillName_"+number).html()+"\",\"LifeTime\":\""+$("#rLifeTime_"+number).html()+"\",\"Mastery\":\""+$("#rMastery_"+number).html()+"\"}]}";
            var json=eval("("+baseInfo+")");
            $.each(json.data,function(idx,item){
		        str=getHTML("Skill_info");
		        str = str.replace(/XNumber/g,number);
		        str = str.replace(/Skill_Button/g,"<img src=images_1/btn_save.gif onclick=Resume_save('Skill_info_"+number+"') style=cursor:pointer><br><a href=\"javascript:void(0);\" onclick=\"deleteinfo('Skill_info_"+number+"')\">删除</a><div class=saveMsg></div>");
		        str = str.replace(/XSkillName/g,"<input name=rSkillName_"+number+" type=text id=rSkillName_"+number+" value='"+$("#rSkillName_"+number).html()+"' \>");
		        str = str.replace(/XLifeTime/g,"<input name=rLifeTime_"+number+" maxlength=4 style='WIDTH: 40px' type=text id=rLifeTime_"+number+" value="+$("#rLifeTime_"+number).html()+"\>");
		        str = str.replace(/XMastery/g,"<select id=rMastery_"+number+" name=rMastery_"+number+" style=\"WIDTH: 80px\" value='"+$("#rMastery_"+number).html()+"'><option>无</option><option>精通</option><option>熟练</option><option>一般</option><option>了解</option></select>");
	            $("#Skill_info_"+number).html(str);
	            SelectItemByText("rMastery_"+number,item.Mastery);
            })
		break;
		case "Cer_info_"+number:
            var baseInfo="{\"data\":[{\"CerName\":\""+$("#rCerName_"+number).html()+"\",\"GetTime\":\""+$("#rGetTime_"+number).html()+"\",\"Mastery\":\""+$("#rMastery_"+number).html()+"\"}]}";
            var json=eval("("+baseInfo+")");
            $.each(json.data,function(idx,item){
		        str=getHTML("Cer_info");
		        str = str.replace(/XNumber/g,number);
		        str = str.replace(/Cer_Button/g,"<img src=images_1/btn_save.gif onclick=Resume_save('Cer_info_"+number+"') style=cursor:pointer><br><a href=\"javascript:void(0);\" onclick=\"deleteinfo('Cer_info_"+number+"')\">删除</a><div class=saveMsg></div>");
		        str = str.replace(/XGetTime/g,"<input class=selebg2 style=CURSOR: hand title=请选择日期 type=button value="+$("#rGetTime_"+number).html()+" id=rGetTime_"+number+"\>");
		        str = str.replace(/XCerName/g,"<input name=rCerName_"+number+" type=text id=rCerName_"+number+" value='"+$("#rCerName_"+number).html()+"' \>");
		        str = str.replace(/XScore/g,"<input name=rScore_"+number+" type=text id=rScore_"+number+" value='"+$("#rScore_"+number).html()+"' \>");
	            $("#Cer_info_"+number).html(str);
	            $(function() {$('#rGetTime_'+number).datepicker({changeMonth: true,changeYear: true});});
            })
		break;
	}
}

function Resume_save(info_id)
{
    var str;
    switch(info_id)
	{
        case "BPI_info":
        var data="{\"id\":\""+rID+"\",\"Name\":\""+$("#rName").attr("value")+"\",\"Born\":\""+$("#rBorn").attr("value")+"\",\"Phone\":\""+$("#rPhone").attr("value")+"\",\"Email\":\""+$("#rEmail").attr("value")+"\",\"Address\":\""+$("#rAddress").attr("value")+"\",\"WorkYears\":\""+$("#rWorkYears").val()+"\",\"Sex\":\""+$("#rSex").val()+"\",\"Birth\":\""+$("#rBirth").attr("value")+"\",\"Save_Time\":\""+nowdate+"\",\"Edu_Time\":\""+$("#rName").attr("value")+"\",\"Exp1_Time\":\""+$("#rName").attr("value")+"\",\"Exp2_Time\":\""+$("#rName").attr("value")+"\",\"Exp3_Time\":\""+$("#rName").attr("value")+"\",\"Cer_Time\":\""+$("#rName").attr("value")+"\"}";
        $.ajax({url: "/facade/Resume.aspx",dataType: "json",data: encodeURI("s_method=save&id="+rID+"&data="+data),
            beforeSend: function(x) {
                x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            },
            complete: function (x) {
                var res = "{\"data\":[" + data + "]}";
                var json=eval("("+res+")");
                $.each(json.data,function(idx,item){
                    str=getHTML("BPI_info");
                    str = str.replace(/BPI_Button/g,"<img src=images_1/btn_amend.gif onclick=editInfo('BPI_info'); style=cursor:pointer><br><div class=saveMsg></div>");
                    str = str.replace(/XName/g,"<span ID=rName>"+item.Name+"</span>");
                    str = str.replace(/XSex/g,"<span ID=rSex>"+item.Sex+"</span>");
                    str = str.replace(/XBirth/g,"<span ID=rBirth>"+item.Birth+"</span>");
                    str = str.replace(/XWorkYears/g,"<span ID=rWorkYears>"+getSelectOption(item.WorkYears)+"</span>");
                    str = str.replace(/XAddress/g,"<span ID=rAddress CssClass=width100p>"+item.Address+"</span>");
                    str = str.replace(/XEmail/g,"<span ID=rEmail>"+item.Email+"</span>");
                    str = str.replace(/XPhone/g,"<span ID=rPhone>"+item.Phone+"</span>");
                    str = str.replace(/XBorn/g,"<span ID=rBorn>"+item.Born+"</span>");
                    $("#BPI_info").html(str);
                })
                $("#dialog_link").hide();
                $("#dialog").hide();
                //$(".saveMsg").html("<p>保存成功</p>");
                //runEffect(".saveMsg");
            }
        });
        break;
        case "Edu_info":
        var data="{\"id\":\""+rID+"\",\"Edu_Time\":\""+$("#rEdu_Time").val()+"\",\"Edu\":\""+$("#rEdu").val()+"\",\"Edu_Degree\":\""+$("#rEdu_Degree").val()+"\",\"Edu_School\":\""+$("#rEdu_School").attr("value")+"\",\"Edu_Subject\":\""+$("#rEdu_Subject").attr("value")+"\"}";
        $.ajax({url: "/facade/Resume.aspx",dataType: "json",data: encodeURI("s_method=save&id="+rID+"&data="+data),
            beforeSend: function(x) {
                x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            },
            complete: function(x) {
                var res = "{\"data\":[" + data + "]}";
                var json=eval("("+res+")");
                $.each(json.data,function(idx,item){
                    str=getHTML("Edu_info");
                    str = str.replace(/Edu_Button/g,"<img src=images_1/btn_amend.gif onclick=editInfo('Edu_info'); style=cursor:pointer><br><div class=saveMsg></div>");
                    str = str.replace(/XEdu_Time/g,"<span ID=rEdu_Time>"+item.Edu_Time+"</span>");
                    str = str.replace(/XEduu/g,"<span ID=rEdu>"+item.Edu+"</span>");
                    str = str.replace(/XEdu_Degree/g,"<span ID=rEdu_Degree>"+item.Edu_Degree+"</span>");
                    str = str.replace(/XEdu_School/g,"<span ID=rEdu_School>"+item.Edu_School+"</span>");
                    str = str.replace(/XEdu_Subject/g,"<span ID=rEdu_Subject CssClass=width100p>"+item.Edu_Subject+"</span>");
                    $("#Edu_info").html(str);
                })
                //$(".saveMsg").html("<p>保存成功</p>");
                //runEffect(".saveMsg");
            }
        });
        break;
        case "Work_info_"+number:
        var data="{\"id\":\""+number+"\",\"ResumeID\":\""+rID+"\",\"StartTime\":\""+$("#rStartTime_"+number).val()+"\",\"EndTime\":\""+$("#rEndTime_"+number).val()+"\",\"Company\":\""+$("#rCompany_"+number).attr("value")+"\",\"Industry\":\""+$("#rIndustry_"+number).attr("value")+"\",\"Department\":\""+$("#rDepartment_"+number).attr("value")+"\",\"Position\":\""+$("#rPosition_"+number).attr("value")+"\",\"Memo\":\""+$("#rMemo_"+number).attr("value")+"\"}";
        $.ajax({url: "/facade/Work.aspx",dataType: "json",data: encodeURI("s_method=save&id="+number+"&data="+data),
            beforeSend: function(x) {
                x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            },
            complete: function(x) {
                var res = "{\"data\":[" + data + "]}";
                var json=eval("("+res+")");
                $.each(json.data,function(idx,item){
                    str=getHTML("Work_info");
                    str = str.replace(/XNumber/g,number);
                    str = str.replace(/Work_Button/g,"<img src=images_1/btn_amend.gif onclick=editInfo('Work_info_"+number+"'); style=cursor:pointer><br><div class=saveMsg></div>");
                    str = str.replace(/XStartTime/g,"<span ID=rStartTime_"+number+">"+item.StartTime+"</span>");
                    str = str.replace(/XEndTime/g,"<span ID=rEndTime_"+number+">"+item.EndTime+"</span>");
                    str = str.replace(/XCompany/g,"<span ID=rCompany_"+number+">"+item.Company+"</span>");
                    str = str.replace(/XIndustry/g,"<span ID=rIndustry_"+number+">"+item.Industry+"</span>");
                    str = str.replace(/XDepartment/g,"<span ID=rDepartment_"+number+" CssClass=width100p>"+item.Department+"</span>");
                    str = str.replace(/XPosition/g,"<span ID=rPosition_"+number+">"+item.Position+"</span>");
                    str = str.replace(/XMemo/g,"<span ID=rMemo_"+number+">"+item.Memo+"</span>");
                    $("#Work_info_"+number).html(str);
                })
                //$(".saveMsg").html("<p>保存成功</p>");
                //runEffect(".saveMsg");
            }
        });
        break;
        case "Skill_info_"+number:
        var data="{\"id\":\""+number+"\",\"ResumeID\":\""+rID+"\",\"SkillName\":\""+$("#rSkillName_"+number).attr("value")+"\",\"LifeTime\":\""+$("#rLifeTime_"+number).attr("value")+"\",\"Mastery\":\""+$("#rMastery_"+number).val()+"\"}";
        $.ajax({url: "/facade/Skill.aspx",dataType: "json",data: encodeURI("s_method=save&id="+number+"&data="+data),
            beforeSend: function(x) {
                x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            },
            complete: function(x) {
                var res = "{\"data\":[" + data + "]}";
                var json=eval("("+res+")");
                $.each(json.data,function(idx,item){
                    str=getHTML("Skill_info");
                    str = str.replace(/XNumber/g,number);
                    str = str.replace(/Skill_Button/g,"<img src=images_1/btn_amend.gif onclick=editInfo('Skill_info_"+number+"'); style=cursor:pointer><br><div class=saveMsg></div>");
                    str = str.replace(/XSkillName/g,"<span ID=rSkillName_"+number+">"+item.SkillName+"</span>");
                    str = str.replace(/XLifeTime/g,"<span ID=rLifeTime_"+number+">"+item.LifeTime+"</span>");
                    str = str.replace(/XMastery/g,"<span ID=rMastery_"+number+">"+item.Mastery+"</span>");
                    $("#Skill_info_"+number).html(str);
                })
                //$(".saveMsg").html("<p>保存成功</p>");
                //runEffect(".saveMsg");
            }
        });
        break;
        case "Cer_info_"+number:
        var data="{\"id\":\""+number+"\",\"ResumeID\":\""+rID+"\",\"CerName\":\""+$("#rCerName_"+number).attr("value")+"\",\"GetTime\":\""+$("#rGetTime_"+number).val()+"\",\"Score\":\""+$("#rScore_"+number).attr("value")+"\"}";
        $.ajax({url: "/facade/Cer.aspx",dataType: "json",data: encodeURI("s_method=save&id="+number+"&data="+data),
            beforeSend: function(x) {
                x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            },
            complete: function(x) {
                var res = "{\"data\":[" + data + "]}";
                var json=eval("("+res+")");
                $.each(json.data,function(idx,item){
                    str=getHTML("Cer_info");
                    str = str.replace(/XNumber/g,number);
                    str = str.replace(/Cer_Button/g,"<img src=images_1/btn_amend.gif onclick=editInfo('Cer_info_"+number+"'); style=cursor:pointer><br><div class=saveMsg></div>");
                    str = str.replace(/XGetTime/g,"<span ID=rGetTime_"+number+">"+item.GetTime+"</span>");
                    str = str.replace(/XCerName/g,"<span ID=rCerName_"+number+">"+item.CerName+"</span>");
                    str = str.replace(/XScore/g,"<span ID=rScore_"+number+">"+item.Score+"</span>");
                    $("#Cer_info_"+number).html(str);
                })
                //$(".saveMsg").html("<p>保存成功</p>");
                //runEffect(".saveMsg");
            }
        });
        break;
    }
}

function addinfo(info_id)
{
    number=Math.floor(Math.random()*256);
    var str;
    switch(info_id)
	{
        case "Work_info":
	        str=getHTML("Work_info");
	        str = str.replace(/XNumber/g,number);
	        str = str.replace(/Work_Button/g,"<img src=images_1/btn_save.gif onclick=saveinfo('Work_info_"+number+"') style=cursor:pointer><br><a href=\"javascript:void(0);\" onclick=\"clearHTML('Work_info_"+number+"')\">删除</a><div class=saveMsg></div>");
	        str = str.replace(/XStartTime/g,"<input class=selebg2 style=CURSOR: hand title=请选择日期 type=button value='2000-01-01' id=rStartTime_"+number+"\>");
	        str = str.replace(/XEndTime/g,"<input class=selebg2 style=CURSOR: hand title=请选择日期 type=button value='2001-01-01' id=rEndTime_"+number+"\>");
	        str = str.replace(/XCompany/g,"<input name=rCompany_"+number+" type=text class=textfield id=rCompany_"+number+" value=''\>");
	        str = str.replace(/XIndustry/g,"<input name=rIndustry_"+number+" type=text class=textfield id=rIndustry_"+number+" value=''\>");
	        str = str.replace(/XDepartment/g,"<input name=rDepartment_"+number+" type=text class=textfield id=rDepartment_"+number+" value=''\>");
	        str = str.replace(/XPosition/g,"<input name=rPosition_"+number+" type=text class=textfield id=rPosition_"+number+" value=''\>");
	        str = str.replace(/XMemo/g,"<input name=rMemo_"+number+" type=text class=textfield id=rMemo_"+number+" value=''\>");
            $("#Work_info_add").append(str);
	        $(function() {$('#rStartTime_'+number).datepicker({changeMonth: true,changeYear: true});});
	        $(function() {$('#rEndTime_'+number).datepicker({changeMonth: true,changeYear: true});});
	    break;
	    case "Skill_info":
	        str=getHTML("Skill_info");
	        str = str.replace(/XNumber/g,number);
	        str = str.replace(/Skill_Button/g,"<img src=images_1/btn_save.gif onclick=saveinfo('Skill_info_"+number+"') style=cursor:pointer><br><a href=\"javascript:void(0);\" onclick=\"clearHTML('Skill_info_"+number+"')\">删除</a><div class=saveMsg></div>");
	        str = str.replace(/XSkillName/g,"<input type=text value='' id=rSkillName_"+number+"\>");
	        str = str.replace(/XLifeTime/g,"<input maxlength=4 style='WIDTH: 40px' type=text value='' id=rLifeTime_"+number+"\>");
	        str = str.replace(/XMastery/g,"<select id=rMastery_"+number+" name=rMastery_"+number+" style=\"WIDTH: 80px\"><option>无</option><option>精通</option><option>熟练</option><option>一般</option><option>了解</option></select>");
            $("#Skill_info").append(str);
            SelectItemByText("rMastery_"+number,"熟练");
	    break;
	    case "Cer_info":
	        str=getHTML("Cer_info");
	        str = str.replace(/XNumber/g,number);
	        str = str.replace(/Cer_Button/g,"<img src=images_1/btn_save.gif onclick=saveinfo('Cer_info_"+number+"') style=cursor:pointer><br><a href=\"javascript:void(0);\" onclick=\"clearHTML('Cer_info_"+number+"')\">删除</a><div class=saveMsg></div>");
	        str = str.replace(/XCerName/g,"<input type=text value='' id=rCerName_"+number+"\>");
	        str = str.replace(/XGetTime/g,"<input class=selebg2 style=CURSOR: hand title=请选择日期 type=button value='2000-01-01' id=rGetTime_"+number+"\>");
	        str = str.replace(/XScore/g,"<input type=text value='' id=rScore_"+number+"\>");
            $("#Cer_info").append(str);
            $(function() {$('#rGetTime_'+number).datepicker({changeMonth: true,changeYear: true});});
	    break;
    }
}
//与Resume_save方法比较，data无需加入id
function saveinfo(info_id)
{
    switch(info_id)
	{
	    case "Work_info_"+number:
        var data="{\"ResumeID\":\""+rID+"\",\"StartTime\":\""+$("#rStartTime_"+number).val()+"\",\"EndTime\":\""+$("#rEndTime_"+number).val()+"\",\"Company\":\""+$("#rCompany_"+number).attr("value")+"\",\"Industry\":\""+$("#rIndustry_"+number).attr("value")+"\",\"Department\":\""+$("#rDepartment_"+number).attr("value")+"\",\"Position\":\""+$("#rPosition_"+number).attr("value")+"\",\"Memo\":\""+$("#rMemo_"+number).attr("value")+"\"}";
        $.ajax({url: "/facade/Work.aspx",dataType: "json",data: encodeURI("s_method=save&id=&data="+data),
            beforeSend: function(x) {
                x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            },
            complete: function(x) {
                var res = "{\"data\":[" + data + "]}";
                var json=eval("("+res+")");
                $.each(json.data,function(idx,item){
                    str=getHTML("Work_info");
                    str = str.replace(/Work_Button/g,"<img src=images_1/btn_amend.gif onclick=editInfo('Work_info_"+number+"'); style=cursor:pointer><br><div class=saveMsg></div>");
                    str = str.replace(/XStartTime/g,"<span ID=rStartTime_"+number+">"+item.StartTime+"</span>");
                    str = str.replace(/XEndTime/g,"<span ID=rEndTime_"+number+">"+item.EndTime+"</span>");
                    str = str.replace(/XCompany/g,"<span ID=rCompany_"+number+">"+item.Company+"</span>");
                    str = str.replace(/XIndustry/g,"<span ID=rIndustry_"+number+">"+item.Industry+"</span>");
                    str = str.replace(/XDepartment/g,"<span ID=rDepartment_"+number+" CssClass=width100p>"+item.Department+"</span>");
                    str = str.replace(/XPosition/g,"<span ID=rPosition_"+number+">"+item.Position+"</span>");
                    str = str.replace(/XMemo/g,"<span ID=rMemo_"+number+">"+item.Memo+"</span>");
                    $("#Work_info_"+number).html(str);
                    //alert(str);
                })
                //$(".saveMsg").html("<p>保存成功</p>");
                //runEffect(".saveMsg");
            }
        });
        break;
        case "Skill_info_"+number:
        var data="{\"ResumeID\":\""+rID+"\",\"SkillName\":\""+$("#rSkillName_"+number).val()+"\",\"LifeTime\":\""+$("#rLifeTime_"+number).val()+"\",\"Mastery\":\""+$("#rMastery_"+number).val()+"\"}";
        $.ajax({url: "/facade/Skill.aspx",dataType: "json",data: encodeURI("s_method=save&id=&data="+data),
            beforeSend: function(x) {
                x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            },
            complete: function(x) {
                var res = "{\"data\":[" + data + "]}";
                var json=eval("("+res+")");
                $.each(json.data,function(idx,item){
                    str=getHTML("Skill_info");
                    str = str.replace(/Skill_Button/g,"<img src=images_1/btn_amend.gif onclick=editInfo('Skill_info_"+number+"'); style=cursor:pointer><br><div class=saveMsg></div>");
                    str = str.replace(/XSkillName/g,"<span ID=rSkillName_"+number+">"+item.SkillName+"</span>");
                    str = str.replace(/XLifeTime/g,"<span ID=rLifeTime_"+number+">"+item.LifeTime+"</span>");
                    str = str.replace(/XMastery/g,"<span ID=rMastery_"+number+">"+item.Mastery+"</span>");
                    $("#Skill_info_"+number).html(str);
                    //alert(str);
                })
                //$(".saveMsg").html("<p>保存成功</p>");
                //runEffect(".saveMsg");
            }
        });
        break;
        case "Cer_info_"+number:
        var data="{\"ResumeID\":\""+rID+"\",\"CerName\":\""+$("#rCerName_"+number).attr("value")+"\",\"GetTime\":\""+$("#rGetTime_"+number).val()+"\",\"Score\":\""+$("#rScore_"+number).attr("value")+"\"}";
        $.ajax({url: "/facade/Cer.aspx",dataType: "json",data: encodeURI("s_method=save&id=&data="+data),
            beforeSend: function(x) {
                x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            },
            complete: function(x) {
                var res = "{\"data\":[" + data + "]}";
                var json=eval("("+res+")");
                $.each(json.data,function(idx,item){
                    str=getHTML("Cer_info");
                    str = str.replace(/XNumber/g,number);
                    str = str.replace(/Cer_Button/g,"<img src=images_1/btn_amend.gif onclick=editInfo('Cer_info_"+number+"'); style=cursor:pointer><br><div class=saveMsg></div>");
                    str = str.replace(/XGetTime/g,"<span ID=rLifeTime_"+number+">"+item.GetTime+"</span>");
                    str = str.replace(/XCerName/g,"<span ID=rCerName_"+number+">"+item.CerName+"</span>");
                    str = str.replace(/XScore/g,"<span ID=rScore_"+number+">"+item.Score+"</span>");
                    $("#Cer_info_"+number).html(str);
                })
                //$(".saveMsg").html("<p>保存成功</p>");
                //runEffect(".saveMsg");
            }
        });
        break;
	}
}

function deleteinfo(info_id)
{
    getNumber(info_id);
    var sure=confirm("确定要删除吗？");
    if(sure){
        switch(info_id)
	    {
    	    case "Work_info_"+number:
            $.ajax({url: "/facade/Work.aspx",dataType: "json",data: encodeURI("s_method=delete&id="+number),
                beforeSend: function(x) {
                    x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                },
                complete: function(x) {
                    $("#Work_info_"+number).html("");
                }
            });
            break;
            case "Skill_info_"+number:
            $.ajax({url: "/facade/Skill.aspx",dataType: "json",data: encodeURI("s_method=delete&id="+number),
                beforeSend: function(x) {
                    x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                },
                complete: function(x) {
                    $("#Skill_info_"+number).html("");
                }
            });
            break;
            case "Cer_info_"+number:
            $.ajax({url: "/facade/Cer.aspx",dataType: "json",data: encodeURI("s_method=delete&id="+number),
                beforeSend: function(x) {
                    x.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                },
                complete: function(x) {
                    $("#Cer_info_"+number).html("");
                }
            });
            break;
        }
	}
}

function clearHTML(info_id)
{
    //getNumber(info_id);
    var sure=confirm("确定要删除吗？");
    if(sure)
        $("#"+info_id).html("");
}

function getNumber(info_id)
{
    if(info_id.indexOf("Work_info_") == 0)
    {
        number = info_id.replace(/Work_info_/g,"");
    }
    if(info_id.indexOf("Skill_info_") == 0)
    {
        number = info_id.replace(/Skill_info_/g,"");
    }
    if(info_id.indexOf("Cer_info_") == 0)
    {
        number = info_id.replace(/Cer_info_/g,"");
    }
}